﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace StripeOne.Core.S1Tools
{
    public static class S1Timestamp
    {
        [DllImport("kernel32.dll")]
        private static extern short QueryPerformanceCounter(ref long x);
        [DllImport("kernel32.dll")]
        private static extern short QueryPerformanceFrequency(ref long x);
        private static long QueryPerformanceFrequency()
        {
            long result = 0L;
            S1Timestamp.QueryPerformanceFrequency(ref result);
            return result;
        }
        public static long GetTimestamp()
        {
            long result = 0L;
            S1Timestamp.QueryPerformanceCounter(ref result);
            return result;
        }
        public static double GetElapsedTime(long startTimestamp, long endTimestamp)
        {
            long num = S1Timestamp.QueryPerformanceFrequency();
            return (double)(endTimestamp - startTimestamp) * 1000.0 / (double)num;
        }
    }
}
